import { createRouter, createWebHistory } from 'vue-router'
import routes from './routes'
import { navInterceptor } from '../utils'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/home/index.vue'),
      meta: { title: '首页' }
    },
    {
      path: '/entry',
      meta: { layout: 'entry' },
      children: [
        {
          path: 'login',
          component: () => import('../views/entry/login.vue'),
          meta: { title: '登录' }
        }
      ]
    },
    ...routes
  ]
})

router.beforeEach((_, __, next) => navInterceptor(next))

export default router
